/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sk.ke.szatmary.peter.jclac.simpleCiphers.examples;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import sk.ke.szatmary.peter.jclac.simpleCiphers.Vigener;
import sk.ke.szatmary.peter.jclac.simpleCiphers.core.SimpleCipher;
import sk.ke.szatmary.peter.jclac.simpleCiphers.SimpleCipherAttr;
import sk.ke.szatmary.peter.jclac.simpleCiphers.core.SimpleCipherException;

/**
 *
 * @author nue
 */
public class VigenerExampleAppB {
    public static void main(String[] args) {
    
        List<SimpleCipherAttr> listAttr;
        listAttr = new ArrayList<SimpleCipherAttr>();
        String key = "myKey";
        listAttr.add(new SimpleCipherAttr(key));
        try {
            String plain = "plain text 4";
            SimpleCipher vigener = new Vigener(listAttr);
            String encrypted = vigener.getEncrypted(plain);
            String decrypted = vigener.getDecrypted(encrypted);
            
            System.out.println("PLAIN STRING: "+plain);
            System.out.println("ENCRYPTED STRING: "+encrypted);
            System.out.println("DECRYPTED STRING: "+decrypted);
            
            List<SimpleCipherAttr> list = vigener.getAttributes();
            System.out.println("INPUT ATTRIBUTE: "+list.get(0).getValue());
            System.out.println("TRANSFORMED ATTRIBUTE: "+list.get(0).getChangedValue());
            
        List<SimpleCipherAttr> listAttrr;
        listAttrr = new ArrayList<SimpleCipherAttr>();
        String keyr = "love";
        listAttrr.add(new SimpleCipherAttr(keyr));
        vigener.setAttributes(listAttrr);
        
            List<SimpleCipherAttr> list2 = vigener.getAttributes();
            System.out.println("INPUT ATTRIBUTE: "+list2.get(0).getValue());
            System.out.println("TRANSFORMED ATTRIBUTE: "+list2.get(0).getChangedValue());
        
        String str = vigener.getDecrypted(encrypted);
        String str2 = vigener.getEncrypted(str);
        
            List<SimpleCipherAttr> list3 = vigener.getAttributes();
            System.out.println("INPUT ATTRIBUTE: "+list3.get(0).getValue());
            System.out.println("TRANSFORMED ATTRIBUTE: "+list3.get(0).getChangedValue());
            System.out.println("ENCRYPTED WITH NEW ATTR: "+encrypted);
            System.out.println("RESULT: "+str);
            System.out.println("RESULT: "+str2);
            
         
        } catch (SimpleCipherException ex) {
            Logger.getLogger(VigenerExampleAppB.class.getName()).log(Level.SEVERE, null, ex);

        }
        
    }
}
